﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace WindowsFormsApplication1
{
    class Bitmapp
    {
        private int width, height;
        private int[,][] Colory;
        private Bitmap Bitmap;

        public Bitmapp(int width, int height)
        {
            this.width = width;
            this.height = height;
            this.Colory=new int[this.width,this.height][];
            Bitmap = new Bitmap(this.width, this.height);

            
        }
        public void WczytajNowaCalaBitmape(Bitmap bitmap)
        {
            this.Bitmap = bitmap;
            for (int i = 0; i < bitmap.Height; i++)
            {
                for (int j = 0; j < bitmap.Width; j++)
                {
                    Color c=bitmap.GetPixel(j,i);
                    this.Colory[j, i][0] = c.R;
                    this.Colory[j, i][1] = c.G;
                    this.Colory[j, i][2] = c.B;
                    Bitmap.SetPixel(j, i, c);
                }
            }
        }
        public void SetPixel(int i ,int j,Color wartosc)
        {
            this.Colory[i, j] = new int[3];
            this.Colory[i, j][0] = wartosc.R;
            this.Colory[i, j][1] = wartosc.G;
            this.Colory[i, j][2] = wartosc.B;
            Bitmap.SetPixel(i, j, wartosc);
        }

        internal Bitmap GetBitmap()
        {
            return this.Bitmap;
        }
        public int GetPixelR(int i,int j)
        {
            return this.Colory[i, j][0];
        }
        public int GetPixelG(int i,int j)
         {
            return this.Colory[i, j][1];
        }
        public int GetPixelB(int i,int j)
         {
            return this.Colory[i, j][2];
        }

        internal Color GetPixel(int j, int i)
        {
            return Color.FromArgb(this.Colory[j, i][0], this.Colory[j, i][1], this.Colory[j, i][2]);
        }
    }
}
